%%%-------------------------------------------------------------------
%%% @author Rain
%%% @copyright (C) 2025, <COMPANY>
%%% @doc
%%% @end
%%%-------------------------------------------------------------------
-module(ls_room_sup).

-behaviour(supervisor).

-export([start_link/0, init/1]).
-export([start_room_sup_child/1]).

start_link() ->
    supervisor:start_link({local, ?MODULE}, ?MODULE, []).

start_room_sup_child(Sup) ->
    ChildSpec = #{id => ?MODULE,
        start => {?MODULE, start_link, []},
        restart => permanent,
        shutdown => infinity,
        type => supervisor,
        modules => [?MODULE]},
    {ok, _} = supervisor:start_child(Sup, ChildSpec).

init([]) ->
    RoomServerChild = #{id => 'ls_room_svr',
        start => {'ls_room_svr', start_link, []},
        restart => permanent,
        shutdown => 2000,
        type => worker,
        modules => ['ls_room_svr']},

    {ok, {#{strategy => simple_one_for_one,
        intensity => 5,
        period => 30}, [RoomServerChild]}
    }.
